package com.hubusugon.dbs.Controller;

import com.hubusugon.dbs.Bean.Person;
import com.hubusugon.dbs.Service.master.MasterTestService;
import com.hubusugon.dbs.Service.slave.SlaveTestService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
public class PersonController {
    @Resource
    MasterTestService masterTestService;
    @Resource
    SlaveTestService slaveTestService;

    @RequestMapping("/getAllPeople")
    @ResponseBody
    public List<Person> getAllPeople(){
        return masterTestService.getAllPerson();
    }
    @RequestMapping("/addPerson")
    @ResponseBody
    public String addPerson(@RequestBody Person person){
        String result = "";
        try {
            slaveTestService.insertPerson(person);
            return "success";
        }catch (Exception e){
            return result + e;
        }
    }
}
